*/
#include "defs.h"
-#include "cet_util.h"
#include "csv_util.h"
#include "garmin_tables.h"
#include "inifile.h"
+#include <QtCore/QString>
#include <cmath>
#include <cstdio>
#include <cstdlib>
bcr_rd_init(const QString& fname)
{
ini = inifile_init(fname, MYNAME);
- if (ini->unicode) {
- cet_convert_init(CET_CHARSET_UTF8, 1);
- }
bcr_init_radius();
}
static void
bcr_data_read()
{
- char* str;
+ QString str;
route_head* route = route_head_alloc();
- if ((str = inifile_readstr(ini, "client", "routename"))) {
+ str = inifile_readstr(ini, "client", "routename");
+ if (!str.isNull()) {
route->rte_name = str;
}
for (int index = 1; index > 0; index ++) {
char station[32];
- char* str;
+ QString str;
int mlat, mlon; /* mercator data */
snprintf(station, sizeof(station), "STATION%d", index);
- if (nullptr == (str = inifile_readstr(ini, "coordinates", station))) {
+ str = inifile_readstr(ini, "coordinates", station);
+ if (str.isNull()) {
break;
}
- if (2 != sscanf(str, "%d,%d", &mlon, &mlat)) {
+ if (2 != sscanf(CSTR(str), "%d,%d", &mlon, &mlat)) {
fatal(MYNAME ": structure error at %s (Coordinates)!\n", station);
}
wpt->shortname = station;
bcr_mercator_to_wgs84(mlat, mlon, &wpt->latitude, &wpt->longitude);
- if (nullptr != (str = inifile_readstr(ini, "client", station))) {
- char* cx = strchr(str, ',');
- if (cx == nullptr) {
+ str = inifile_readstr(ini, "client", station);
+ if (!str.isNull()) {
+ int cx = str.indexOf(',');
+ if (cx < 0) {
fatal(MYNAME ": structure error at %s (Client)!\n", station);
}
- *cx++ = '\0';
- bcr_handle_icon_str(str, wpt);
+ bcr_handle_icon_str(CSTR(str.left(cx)), wpt);
}
- if (nullptr != (str = inifile_readstr(ini, "description", station))) {
- char* c = strchr(str, ',');
- if (c != nullptr) {
- *c = '\0';
- }
- if (*str) {
- wpt->notes = str;
+ str = inifile_readstr(ini, "description", station);
+ if (!str.isNull()) {
+ QString note = str.section(',', 0, 0);
+ if (!note.isEmpty()) {
+ wpt->notes = note;
}
- if ((str = c)) {
- str++;
- c = strchr(str, ',');
- if (c != nullptr) {
- *c = '\0';
- }
- if (*str) {
- wpt->shortname = str;
- }
+ QString shortname = str.section(',', 1, 1);
+ if (!shortname.isEmpty()) {
+ wpt->shortname = shortname;
}
}
#include "validate.h"
#include "gbversion.h"
#include "inifile.h"
-#include <QtCore/QStringList>
+#include <QtCore/QString>
#include <cstdio>
#include <cstdlib>
#include <cstdlib> // qsort
struct arglist* args = vec->vec->get_args();
if (args) {
for (ap = args; ap->argstring; ap++) {
- const char* temp = inifile_readstr(global_opts.inifile, vec->name, ap->argstring);
- if (temp == nullptr) {
- temp = inifile_readstr(global_opts.inifile, "Common filter settings", ap->argstring);
+ QString qtemp = inifile_readstr(global_opts.inifile, vec->name, ap->argstring);
+ if (qtemp.isNull()) {
+ qtemp = inifile_readstr(global_opts.inifile, "Common filter settings", ap->argstring);
}
- if (temp == nullptr) {
- temp = ap->defaultvalue;
+ if (qtemp.isNull()) {
+ assign_option(vec->name, ap, ap->defaultvalue);
+ } else {
+ assign_option(vec->name, ap, CSTR(qtemp));
}
- assign_option(vec->name, ap, temp);
}
}
#include "garmin_tables.h"
#include "inifile.h"
+#include <QtCore/QString>
#include <QtCore/QXmlStreamWriter>
#include <cassert>
#include <cstdio>
// warning: ā%dā directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Wformat-truncation=]
assert((i>=0) && (i<16));
snprintf(key, sizeof(key), "%d", i + 1);
- char* c = inifile_readstr(global_opts.inifile, GMSD_SECTION_CATEGORIES, key);
- if ((c != nullptr) && (case_ignore_strcmp(c, category_name) == 0)) {
+ QString c = inifile_readstr(global_opts.inifile, GMSD_SECTION_CATEGORIES, key);
+ if (c.compare(category_name, Qt::CaseInsensitive) == 0) {
cat = (1 << i);
break;
}
#include "jeeps/gpsmath.h"
#include "strptime.h"
+#include <QtCore/QString>
#include <cmath>
#include <cstdlib> // qsort
static void
print_categories(uint16_t categories)
{
- char* c;
-
if (categories == 0) {
return;
}
int count = 0;
for (int i = 0; i < 16; i++) {
if ((categories & 1) != 0) {
+ QString c;
if (global_opts.inifile != nullptr) {
char key[3];
snprintf(key, sizeof(key), "%d", i + 1);
c = inifile_readstr(global_opts.inifile, GMSD_SECTION_CATEGORIES, key);
- } else {
- c = nullptr;
}
gbfprintf(fout, "%s", (count++ > 0) ? "," : "");
- if (c == nullptr) {
+ if (c.isNull()) {
gbfprintf(fout, "Category %d", i+1);
}
// gbfprintf(fout, "%s", gps_categories[i]);
else {
- gbfprintf(fout, "%s", c);
+ gbfprintf(fout, "%s", CSTR(c));
}
}
*/
#include "defs.h"
-#include "cet_util.h"
#include "grtcirc.h"
#include "inifile.h"
+#include <QtCore/QString>
#include <cmath>
#include <cstdio>
#include <cstdlib>
ggv_ovl_rd_init(const QString& fname)
{
inifile = inifile_init(fname, MYNAME);
- if (inifile->unicode) {
- cet_convert_init(CET_CHARSET_UTF8, 1);
- }
route_ct = 0;
track_ct = 0;
OVL_SYMBOL_TYP type = (OVL_SYMBOL_TYP) inifile_readint_def(inifile, symbol, "Typ", 0);
int points = inifile_readint_def(inifile, symbol, "Punkte", -1);
+ QString lat;
+ QString lon;
switch (type) {
char coord[32];
Waypoint* wpt;
- char* cx;
int group;
case OVL_SYMBOL_LINE:
wpt = new Waypoint;
snprintf(coord, sizeof(coord), "YKoord%d", j);
- if ((cx = inifile_readstr(inifile, symbol, coord))) {
- wpt->latitude = atof(cx);
+ lat = inifile_readstr(inifile, symbol, coord);
+ if (!lat.isNull()) {
+ wpt->latitude = lat.toDouble();
} else {
continue;
}
snprintf(coord, sizeof(coord), "XKoord%d", j);
- if ((cx = inifile_readstr(inifile, symbol, coord))) {
- wpt->longitude = atof(cx);
+ lon = inifile_readstr(inifile, symbol, coord);
+ if (!lon.isNull()) {
+ wpt->longitude = lon.toDouble();
} else {
continue;
}
wpt = new Waypoint;
wpt->shortname = symbol;
- if ((cx = inifile_readstr(inifile, symbol, "YKoord"))) {
- wpt->latitude = atof(cx);
+ lat = inifile_readstr(inifile, symbol, "YKoord");
+ if (!lat.isNull()) {
+ wpt->latitude = lat.toDouble();
} else {
continue;
}
- if ((cx = inifile_readstr(inifile, symbol, "XKoord"))) {
- wpt->longitude = atof(cx);
+ lon = inifile_readstr(inifile, symbol, "XKoord");
+ if (!lon.isNull()) {
+ wpt->longitude = lon.toDouble();
} else {
continue;
}
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
-#include "defs.h"
+#include "defs.h" // for fatal, ugetenv, warning
#include "inifile.h"
-#include <QtCore/QDir>
-#include <QtCore/QFile>
-#include <cstdio>
-#include <cstdlib>
+#include "src/core/file.h" // for File
+#include <QtCore/QByteArray> // for QByteArray
+#include <QtCore/QChar> // for operator==, QChar
+#include <QtCore/QDir> // for QDir
+#include <QtCore/QFile> // for QFile
+#include <QtCore/QFileInfo> // for QFileInfo
+#include <QtCore/QHash> // for QHash
+#include <QtCore/QIODevice> // for QIODevice::ReadOnly, QIODevice
+#include <QtCore/QTextStream> // for QTextStream
+#include <QtCore/Qt> // for CaseInsensitive
+#include <QtCore/QtGlobal> // for qPrintable
#define MYNAME "inifile"
-typedef struct inifile_entry_s {
- queue Q;
- char* key;
- char* val;
-} inifile_entry_t;
+class InifileSection
+{
+public:
+ QString name;
+ QHash<QString, QString> entries;
-typedef struct inifile_section_s {
- queue Q;
- char* name;
- int ientries;
- queue entries;
-} inifile_section_t;
+ InifileSection() = default;
+ explicit InifileSection(QString nm) : name{nm} {}
+};
/* internal procedures */
-#define START_BUFSIZE 257
-#define DELTA_BUFSIZE 128
-
#define GPSBABEL_INIFILE "gpsbabel.ini"
#define GPSBABEL_SUBDIR ".gpsbabel"
-/* Remember the filename we used so we can include it in errors. */
-static QString gbinipathname;
static QString
find_gpsbabel_inifile(const QString& path) /* can be empty or NULL */
return QFile(inipath).open(QIODevice::ReadOnly) ? inipath : QString();
}
-static gbfile*
+static QString
open_gpsbabel_inifile()
{
- gbfile* res = nullptr;
+ QString res;
QString envstr = ugetenv("GPSBABELINI");
if (!envstr.isNull()) {
if (QFile(envstr).open(QIODevice::ReadOnly)) {
- return gbfopen(envstr, "r", "GPSBabel");
+ return envstr;
}
warning("WARNING: GPSBabel-inifile, defined in environment, NOT found!\n");
- return nullptr;
+ return res;
}
QString name = find_gpsbabel_inifile(""); // Check in current directory first.
if (name.isNull()) {
// Use &&'s early-out behaviour to try successive file locations: first
// %APPDATA%, then %WINDIR%, then %SYSTEMROOT%.
(name = find_gpsbabel_inifile(ugetenv("APPDATA"))).isNull()
- && (name = find_gpsbabel_inifile(ugetenv("WINDIR"))).isNull()
- && (name = find_gpsbabel_inifile(ugetenv("SYSTEMROOT"))).isNull();
+ && (name = find_gpsbabel_inifile(ugetenv("WINDIR"))).isNull()
+ && (name = find_gpsbabel_inifile(ugetenv("SYSTEMROOT"))).isNull();
#else
// Use &&'s early-out behaviour to try successive file locations: first
// ~/.gpsbabel, then /usr/local/etc, then /etc.
(name = find_gpsbabel_inifile(QDir::home().filePath(GPSBABEL_SUBDIR))).
- isNull()
- && (name = find_gpsbabel_inifile("/usr/local/etc")).isNull()
- && (name = find_gpsbabel_inifile("/etc")).isNull();
+ isNull()
+ && (name = find_gpsbabel_inifile("/usr/local/etc")).isNull()
+ && (name = find_gpsbabel_inifile("/etc")).isNull();
#endif
}
if (!name.isNull()) {
- res = gbfopen(name, "r", "GPSBabel");
- gbinipathname = name;
+ res = name;
}
return res;
}
static void
-inifile_load_file(gbfile* fin, inifile_t* inifile, const char* myname)
+inifile_load_file(QTextStream* stream, inifile_t* inifile, const char* myname)
{
- char* buf;
- inifile_section_t* sec = nullptr;
- int line = 0;
+ QString buf;
+ InifileSection section;
- while ((buf = gbfgetstr(fin))) {
- char* cin = lrtrim(buf);
-
- if ((line++ == 0) && fin->unicode) {
- inifile->unicode = 1;
- }
+ while (!(buf = stream->readLine()).isNull()) {
+ buf = buf.trimmed();
- if (*cin == '\0') {
+ if (buf.isEmpty()) {
continue; /* skip empty lines */
}
- if ((*cin == '#') || (*cin == ';')) {
+ if ((buf.at(0) == '#') || (buf.at(0) == ';')) {
continue; /* skip comments */
}
- if (*cin == '[') {
-
- char* cend = strchr(++cin, ']');
-
- if (cend != nullptr) {
- *cend = '\0';
- cin = lrtrim(cin);
+ if (buf.at(0) == '[') {
+ QString section_name;
+ if (buf.contains(']')) {
+ section_name = buf.mid(1, buf.indexOf(']') - 1).trimmed();
}
- if ((*cin == '\0') || (cend == nullptr)) {
- fatal("%s: invalid section header '%s' in '%s'.\n", myname, cin,
- qPrintable(gbinipathname));
+ if (section_name.isEmpty()) {
+ fatal("%s: invalid section header '%s' in '%s'.\n", myname, qPrintable(section_name),
+ qPrintable(inifile->source));
}
- sec = (inifile_section_t*) xcalloc(1, sizeof(*sec));
-
- sec->name = xstrdup(cin);
- QUEUE_INIT(&sec->entries);
- ENQUEUE_TAIL(&inifile->secs, &sec->Q);
- inifile->isecs++;
+ // form lowercase key to implement CaseInsensitive matching.
+ section_name = section_name.toLower();
+ inifile->sections.insert(section_name, InifileSection(section_name));
+ section = inifile->sections.value(section_name);
} else {
- if (sec == nullptr) {
+ if (section.name.isEmpty()) {
fatal("%s: missing section header in '%s'.\n", myname,
- qPrintable(gbinipathname));
+ qPrintable(inifile->source));
}
- inifile_entry_t* entry = (inifile_entry_t*) xcalloc(1, sizeof(*entry));
- ENQUEUE_TAIL(&sec->entries, &entry->Q);
- sec->ientries++;
-
- char* cx = strchr(cin, '=');
- if (cx != nullptr) {
- *cx = '\0';
- cin = lrtrim(cin);
- }
-
- entry->key = xstrdup(cin);
-
- if (cx != nullptr) {
- cx = lrtrim(++cx);
- entry->val = xstrdup(cx);
- } else {
- entry->val = xstrdup("");
- }
+ // Store key in lower case to implement CaseInsensitive matching.
+ QString key = buf.section('=', 0, 0).trimmed().toLower();
+ // Take some care so the return from inifile_find_value can
+ // be used to distinguish between a key that isn't found
+ // and a found key without a value, i.e. force value
+ // to be non-null but possibly empty.
+ QString value = buf.section('=', 1).append("").trimmed();
+ section.entries.insert(key, value);
+
+ // update the QHash sections with the modified InifileSection section.
+ inifile->sections.insert(section.name, section);
}
}
}
-static char*
-inifile_find_value(const inifile_t* inifile, const char* sec_name, const char* key)
+static const QString
+inifile_find_value(const inifile_t* inifile, const QString& sec_name, const QString& key)
{
- queue* elem, *tmp;
-
if (inifile == nullptr) {
- return nullptr;
+ return QString();
}
- QUEUE_FOR_EACH(&inifile->secs, elem, tmp) {
- inifile_section_t* sec = reinterpret_cast<inifile_section_t *>(elem);
-
- if (case_ignore_strcmp(sec->name, sec_name) == 0) {
- queue* elem, *tmp;
-
- QUEUE_FOR_EACH(&sec->entries, elem, tmp) {
- inifile_entry_t* entry = reinterpret_cast<inifile_entry_t *>(elem);
-
- if (case_ignore_strcmp(entry->key, key) == 0) {
- return entry->val;
- }
- }
- }
- }
- return nullptr;
+ // CaseInsensitive matching implemented by forcing sec_name & key to lower case.
+ return inifile->sections.value(sec_name.toLower()).entries.value(key.toLower());
}
/* public procedures */
inifile_t*
inifile_init(const QString& filename, const char* myname)
{
- gbfile* fin = nullptr;
+ QString name;
if (filename.isEmpty()) {
- fin = open_gpsbabel_inifile();
- if (fin == nullptr) {
+ name = open_gpsbabel_inifile();
+ if (name.isEmpty()) {
return nullptr;
}
} else {
- fin = gbfopen(filename, "rb", myname);
+ name = filename;
}
- inifile_t* result = (inifile_t*) xcalloc(1, sizeof(*result));
- QUEUE_INIT(&result->secs);
- inifile_load_file(fin, result, myname);
+ gpsbabel::File file(name);
+ file.open(QFile::ReadOnly);
+ QTextStream stream(&file);
+ stream.setCodec("UTF-8");
+ stream.setAutoDetectUnicode(true);
+
+ auto* result = new inifile_t;
+ QFileInfo fileinfo(file);
+ result->source = fileinfo.absoluteFilePath();
+ inifile_load_file(&stream, result, myname);
- gbfclose(fin);
+ file.close();
return result;
}
void
inifile_done(inifile_t* inifile)
{
- if (inifile == nullptr) {
- return;
- }
-
- if (inifile->isecs > 0) {
- queue* elem, *tmp;
-
- QUEUE_FOR_EACH(&inifile->secs, elem, tmp) {
- inifile_section_t* sec = reinterpret_cast<inifile_section_t *>(elem);
-
- if (sec->ientries > 0) {
- queue* elem, *tmp;
-
- QUEUE_FOR_EACH(&sec->entries, elem, tmp) {
- inifile_entry_t* entry = reinterpret_cast<inifile_entry_t *>(elem);
-
- if (entry->key) {
- xfree(entry->key);
- }
- if (entry->val) {
- xfree(entry->val);
- }
- dequeue(elem);
- xfree(entry);
- }
- }
- dequeue(elem);
- if (sec->name) {
- xfree(sec->name);
- }
- xfree(sec);
- }
- xfree(inifile);
- }
- gbinipathname.clear();
+ delete inifile;
}
-int
+bool
inifile_has_section(const inifile_t* inifile, const char* section)
{
- queue* elem, *tmp;
-
- QUEUE_FOR_EACH(&inifile->secs, elem, tmp) {
- inifile_section_t* sec = reinterpret_cast<inifile_section_t *>(elem);
- if (case_ignore_strcmp(sec->name, section) == 0) {
- return 1;
- }
- }
- return 0;
+ return inifile->sections.contains(QString(section).toLower());
}
/*
inifile_readstr:
- returns NULL if not found, otherwise a pointer to the value of key ...
- all key values are valid entities until "inifile_done"
+ returns a null QString if not found, otherwise a non-null but possibly
+ empty Qstring with the value of key ...
*/
-char*
+QString
inifile_readstr(const inifile_t* inifile, const char* section, const char* key)
{
return inifile_find_value(inifile, section, key);
int
inifile_readint(const inifile_t* inifile, const char* section, const char* key, int* value)
{
- char* str = inifile_find_value(inifile, section, key);
+ const QString str = inifile_find_value(inifile, section, key);
- if (str == nullptr) {
+ if (str.isNull()) {
return 0;
}
if (value != nullptr) {
- *value = atoi(str);
+ *value = str.toInt();
}
return 1;
}
#ifndef HAVE_INIFILE_H
#define HAVE_INIFILE_H
-#include "defs.h"
+#include <QtCore/QHash> // for QHash
+#include <QtCore/QList> // for QList
+#include <QtCore/QString> // for QString
-typedef struct inifile_s {
- int isecs; /* number of sections */
- queue secs; /* sections */
- uint8_t unicode:1;
-} inifile_t;
+class InifileSection;
+struct inifile_t {
+ QHash<QString, InifileSection> sections;
+ QString source;
+};
/*
inifile_init:
inifile_t* inifile_init(const QString& filename, const char* myname);
void inifile_done(inifile_t* inifile);
-int inifile_has_section(const inifile_t* inifile, const char* section);
+bool inifile_has_section(const inifile_t* inifile, const char* section);
/*
inifile_readstr:
- returns NULL if not found, otherwise a pointer to the value of key ...
- all key values are valid entities until "inifile_done"
+ returns a null QString if not found, otherwise a non-null but possibly
+ empty Qstring with the value of key ...
*/
-char* inifile_readstr(const inifile_t* inifile, const char* section, const char* key);
+QString inifile_readstr(const inifile_t* inifile, const char* section, const char* key);
/*
inifile_readint:
*/
#include "defs.h"
-#include "cet_util.h"
#include "csv_util.h"
#include "inifile.h"
+#include <QtCore/QString>
#include <cctype>
#include <cstdio>
#include <cstdlib>
raymarine_rd_init(const QString& fname)
{
fin = inifile_init(fname, MYNAME);
- if (fin->unicode) {
- cet_convert_init(CET_CHARSET_UTF8, 1);
- }
}
static void
for (unsigned int ix = 0; ix < 0x3FFF; ix++) {
char sect[10];
- char* str, *name, *lat, *lon;
+ QString str, name, lat, lon;
/* built section identifier */
snprintf(sect, sizeof(sect), "Wp%d", ix);
/* try to read our most expected values */
- if (nullptr == (name = inifile_readstr(fin, sect, "Name"))) {
+ name = inifile_readstr(fin, sect, "Name");
+ if (name.isNull()) {
break;
}
- if (nullptr == (lat = inifile_readstr(fin, sect, "Lat"))) {
+ lat = inifile_readstr(fin, sect, "Lat");
+ if (lat.isNull()) {
break;
}
- if (nullptr == (lon = inifile_readstr(fin, sect, "Long"))) {
+ lon = inifile_readstr(fin, sect, "Long");
+ if (lon.isNull()) {
break;
}
Waypoint* wpt = new Waypoint;
wpt->shortname = name;
- wpt->latitude = atof(lat);
- wpt->longitude = atof(lon);
+ wpt->latitude = lat.toDouble();
+ wpt->longitude = lon.toDouble();
waypt_add(wpt);
/* try to read optional values */
- if (((str = inifile_readstr(fin, sect, "Notes"))) && *str) {
+ str = inifile_readstr(fin, sect, "Notes");
+ if (!str.isEmpty()) {
wpt->notes = str;
}
- if (((str = inifile_readstr(fin, sect, "Time"))) && *str) {
- wpt->SetCreationTime(EXCEL_TO_TIMET(atof(str)));
+ str = inifile_readstr(fin, sect, "Time");
+ if (!str.isEmpty()) {
+ wpt->SetCreationTime(EXCEL_TO_TIMET(str.toDouble()));
}
- if (((str = inifile_readstr(fin, sect, "Bmp"))) && *str) {
- unsigned int symbol = atoi(str);
+ str = inifile_readstr(fin, sect, "Bmp");
+ if (!str.isEmpty()) {
+ unsigned int symbol = str.toInt();
if ((symbol < 3) && (symbol >= RAYMARINE_SYMBOL_CT)) {
symbol = RAYMARINE_STD_SYMBOL;
for (unsigned int rx = 0; rx < 0x3FFF; rx++) {
char sect[10];
- char* name;
+ QString name;
snprintf(sect, sizeof(sect), "Rt%d", rx);
- if (nullptr == (name = inifile_readstr(fin, sect, "Name"))) {
+ name = inifile_readstr(fin, sect, "Name");
+ if (name.isNull()) {
break;
}
char buff[32];
snprintf(buff, sizeof(buff), "Mk%d", wx);
- char* str = inifile_readstr(fin, sect, buff);
- if ((str == nullptr) || (*str == '\0')) {
+ QString str = inifile_readstr(fin, sect, buff);
+ if (str.isEmpty()) {
break;
}
Waypoint* wpt = find_waypt_by_name(str);
if (wpt == nullptr)
fatal(MYNAME ": No associated waypoint for route point %s (Route %s)!\n",
- str, qPrintable(rte->rte_name));
+ qPrintable(str), qPrintable(rte->rte_name));
route_add_wpt(rte, new Waypoint(*wpt));
}
#include "csv_util.h"
#include "gbversion.h"
#include "inifile.h"
+#include <QtCore/QString>
#include <cstdio>
#include <cstdlib> // qsort
if (vec->vec->args) {
for (auto ap = vec->vec->args; ap->argstring; ap++) {
- const char* opt;
-
if (res) {
- opt = get_option(*opts, ap->argstring);
+ const char* opt = get_option(*opts, ap->argstring);
if (opt) {
found = 1;
assign_option(svecname, ap, opt);
continue;
}
}
- opt = inifile_readstr(global_opts.inifile, vec->name, ap->argstring);
- if (opt == nullptr) {
- opt = inifile_readstr(global_opts.inifile, "Common format settings", ap->argstring);
+ QString qopt = inifile_readstr(global_opts.inifile, vec->name, ap->argstring);
+ if (qopt.isNull()) {
+ qopt = inifile_readstr(global_opts.inifile, "Common format settings", ap->argstring);
}
- if (opt == nullptr) {
- opt = ap->defaultvalue;
+ if (qopt.isNull()) {
+ assign_option(vec->name, ap, ap->defaultvalue);
+ } else {
+ assign_option(vec->name, ap, CSTR(qopt));
}
- assign_option(vec->name, ap, opt);
}
}
if (opts && opts[0] && !found) {
if (vec_list[0].vec->args) {
for (auto ap = vec_list[0].vec->args; ap->argstring; ap++) {
- const char* opt;
-
if (res) {
- opt = get_option(*opts, ap->argstring);
+ const char* opt = get_option(*opts, ap->argstring);
if (opt) {
found = 1;
assign_option(svecname, ap, opt);
continue;
}
}
- opt = inifile_readstr(global_opts.inifile, svec->name, ap->argstring);
- if (opt == nullptr) {
- opt = inifile_readstr(global_opts.inifile, "Common format settings", ap->argstring);
+ QString qopt = inifile_readstr(global_opts.inifile, svec->name, ap->argstring);
+ if (qopt.isNull()) {
+ qopt = inifile_readstr(global_opts.inifile, "Common format settings", ap->argstring);
}
- if (opt == nullptr) {
- opt = ap->defaultvalue;
+ if (qopt.isNull()) {
+ assign_option(svec->name, ap, ap->defaultvalue);
+ } else {
+ assign_option(svec->name, ap, CSTR(qopt));
}
- assign_option(svec->name, ap, opt);
}
}